import java.util.Scanner;

/**
 * 
 * @author victor
 * 
 */
public class TorresHanoi {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		System.out.println("Numero de discos: ");
		n = sc.nextInt();
		ToresDeHanoiIterativo(n, "1", "2", "3"); // 1:origen 2:auxiliar
													// 3:destino
	}

	private static void ToresDeHanoiIterativo(int nroDiscos, String origen, String destino, String auxiliar) {
		String[] pilaO = new String[10], pilaD = new String[10], pilaX = new String[10];
		int[] pilaN = new int[10];
		int tope;
		String varaux;
		boolean band;
		
		tope = 0;
		band = false;

		while (nroDiscos > 0 && band == false) {
			while (nroDiscos > 1) {
				tope = tope + 1;
				pilaN[tope] = nroDiscos;
				pilaO[tope] = origen;
				pilaD[tope] = destino;
				pilaX[tope] = auxiliar;
				nroDiscos = nroDiscos - 1;
				varaux = destino;
				destino = auxiliar;
				auxiliar = varaux;
			}

			System.out.println(nroDiscos + ": " + origen + " -> " + destino);
			band = true;
			
			if (tope > 0) {
				nroDiscos = pilaN[tope];
				origen = pilaO[tope];
				destino = pilaD[tope];
				auxiliar = pilaX[tope];
				tope = tope - 1;
				System.out.println(nroDiscos + ": " + origen + " -> " + destino);

				nroDiscos = nroDiscos - 1;
				varaux = origen;
				origen = auxiliar;
				auxiliar = varaux;
				band = false;
			}
		}
	}
}
